package com.lihuanyu.upcOA.service;

import com.lihuanyu.upcOA.conn.databaseUtil;
import com.lihuanyu.upcOA.model.userTable;


/**
 * Created by skyADMIN on 15/8/30.
 */
public class register {
    public int regIn(userTable user){
        String role = user.getRole();
        if(role.equals("student")){
            String sql = "INSERT INTO `student_login`(`username`, `password`) VALUES ('"+user.getUsername()+"','"+user.getPassword()+"')";
            databaseUtil db = new com.lihuanyu.upcOA.conn.databaseUtil();
            db.executeUpdate(sql);
            sql = "INSERT INTO `student_info`(`username`) VALUES ('"+user.getUsername()+"')";
            db.executeUpdate(sql);
            db.sqlclose();
            return 1;
        }else {
            String sql = "INSERT INTO `teacher_reg`(`username`, `password`) VALUES ('"+user.getUsername()+"','"+user.getPassword()+"')";
            databaseUtil db = new com.lihuanyu.upcOA.conn.databaseUtil();
            db.executeUpdate(sql);
            db.sqlclose();
            return 2;
        }
    }
}
